<html>
<head><meta charset="utf-8"><title>1670: fs wrappers · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html">1670: fs wrappers</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="175263869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175263869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> LDSpits <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175263869">(Sep 09 2019 at 17:30)</a>:</h4>
<p>Hey, I'm currently working at <a href="https://github.com/rust-analyzer/rust-analyzer/issues/1670" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/1670">https://github.com/rust-analyzer/rust-analyzer/issues/1670</a>. But it feels like the impact of the change is a bit bigger than expected</p>



<a name="175264437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175264437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175264437">(Sep 09 2019 at 17:36)</a>:</h4>
<p><span class="user-mention" data-user-id="212285">@LDSpits</span> why is that?</p>



<a name="175264564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175264564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> LDSpits <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175264564">(Sep 09 2019 at 17:38)</a>:</h4>
<p>There does not seem to be a direct replacement for the existSync call. I found 2 solutions though.</p>



<a name="175264636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175264636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175264636">(Sep 09 2019 at 17:39)</a>:</h4>
<p>We can replace everything except existsSync, and leave a FIXME :-)</p>



<a name="175264849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175264849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> LDSpits <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175264849">(Sep 09 2019 at 17:41)</a>:</h4>
<p>I can use <code>workspace.fs.stat</code> and use the failure as an <code>existsync</code>. Or i can use <code>workspace.findfiles</code> to search for the <code>cargo.toml</code></p>



<a name="175264962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175264962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175264962">(Sep 09 2019 at 17:42)</a>:</h4>
<p>fs.stat seems like the right approach</p>



<a name="175264976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175264976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> LDSpits <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175264976">(Sep 09 2019 at 17:42)</a>:</h4>
<p>i feel like the FindFiles solution might actually be more complete here.</p>



<a name="175265035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175265035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> LDSpits <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175265035">(Sep 09 2019 at 17:43)</a>:</h4>
<p>That way we can open Directories where the cargo.toml is not at the root (which the code currently assumes)</p>



<a name="175265132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175265132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> LDSpits <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175265132">(Sep 09 2019 at 17:44)</a>:</h4>
<p>however, I'll have to do more than just replace <code>fs.existSync</code>...</p>



<a name="175265148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175265148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175265148">(Sep 09 2019 at 17:44)</a>:</h4>
<p>yeah, that seems resonable.</p>



<a name="175265166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175265166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175265166">(Sep 09 2019 at 17:44)</a>:</h4>
<p>However, doing fs.stat for startes I assume would be  smaller diff</p>



<a name="175265178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175265178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175265178">(Sep 09 2019 at 17:44)</a>:</h4>
<p>and replacing it with findFiles seems like a separate refactoring</p>



<a name="175265179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175265179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> LDSpits <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175265179">(Sep 09 2019 at 17:44)</a>:</h4>
<p>that is true</p>



<a name="175265280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175265280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> LDSpits <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175265280">(Sep 09 2019 at 17:46)</a>:</h4>
<p>Ok, I'll replace the call with <code>fs.stat</code> first then. Should I open an issue about the locating of cargo.toml after that?</p>



<a name="175265404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175265404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175265404">(Sep 09 2019 at 17:47)</a>:</h4>
<p>yeah, I think openning an issue would be useful. Could you also research what happens now if Cargo.toml is not at the root? I think that the server side might miss this as well.</p>



<a name="175268208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175268208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> LDSpits <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175268208">(Sep 09 2019 at 18:14)</a>:</h4>
<p>Rust-analyzer currently throws <code>[ra_lsp_server::main_loop] loading workspace failed: can't find Cargo.toml</code> when attempting to load with a non-root cargo.toml from the server</p>



<a name="175275972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175275972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175275972">(Sep 09 2019 at 19:46)</a>:</h4>
<p>can workspaces have their Cargo.toml in a random subdirectory? how does it work?</p>



<a name="175313437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/1670%3A%20fs%20wrappers/near/175313437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/1670.3A.20fs.20wrappers.html#175313437">(Sep 10 2019 at 07:40)</a>:</h4>
<p>I think this is for if you gave:</p>
<div class="codehilite"><pre><span></span>vscode-workspace
| Backend/
|| Cargo.toml
|| src/
||| main.rs
| Frontend/
|| index.ts
|| tsconfig.json
</pre></div>


<p>Currently, we fail if you open <a href="http://main.rs" target="_blank" title="http://main.rs">main.rs</a>, but ideally we would detect that it is in the Backend project</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>